package com.chenxin.wms.controller;

import com.chenxin.common.constant.WmsConstants;
import com.chenxin.common.core.domain.AjaxResult;
import com.chenxin.common.core.domain.ProcResult;
import com.chenxin.wms.domain.dto.ArriveSimulateParams;
import com.chenxin.wms.domain.dto.DownSimulateParams;
import com.chenxin.wms.domain.dto.UpSimulateParams;
import com.chenxin.wms.process.simulate.IProcArriveSimulate;
import com.chenxin.wms.process.simulate.IProcDownSimulate;
import com.chenxin.wms.process.simulate.IProcUpSimulate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/wms/simulate")
public class SimulateController {
    @Autowired
    private IProcUpSimulate procUpSimulate;
    @Autowired
    private IProcDownSimulate procDownSimulate;
    @Autowired
    private IProcArriveSimulate procArriveSimulate;

    @PostMapping("/up")
    public AjaxResult upSimulate(@RequestBody UpSimulateParams params) {
        ProcResult procResult = procUpSimulate.call(params);
        if (WmsConstants.PROC_SUCCESS.equals(procResult.getCode())) {
            return AjaxResult.success(procResult.getMessage());
        } else {
            return AjaxResult.error(procResult.getMessage());
        }
    }

    @PostMapping("/down")
    public AjaxResult downSimulate(@RequestBody DownSimulateParams params) {
        ProcResult procResult = procDownSimulate.call(params);
        if (WmsConstants.PROC_SUCCESS.equals(procResult.getCode())) {
            return AjaxResult.success(procResult.getMessage());
        } else {
            return AjaxResult.error(procResult.getMessage());
        }
    }

    @PostMapping("/arrive")
    public AjaxResult arriveSimulate(@RequestBody ArriveSimulateParams params) {
        ProcResult procResult = procArriveSimulate.call(params);
        if (WmsConstants.PROC_SUCCESS.equals(procResult.getCode())) {
            return AjaxResult.success(procResult.getMessage());
        } else {
            return AjaxResult.error(procResult.getMessage());
        }
    }
}
